package com.dxl.rest;

import com.dxl.common.AlipayProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * Description: 获取配置文件的类
 *
 * @author: Yingyu Wei
 * <p>File Created at 2021/4/4</p>
 */
@RestController
public class ConfigurationPropertiesController {

    @Autowired
    private AlipayProperties alipayProperties;

    @GetMapping("/configurationProperties")
    public String getValues() {

        /*为什么属性值都是null？突然就明白了，new一个对象，就使用了新的地址值，就不是原来的了。*/
        AlipayProperties alipay = new AlipayProperties();
        System.out.println(alipay.toString());// AlipayProperties{appid='null', email='null', key='null', productNo='null'}

        AlipayProperties alipayProperties = this.alipayProperties;
        System.out.println(alipayProperties);//AlipayProperties{appid='33333', email='xuchengfeifei@q163.com', key='2', productNo='3'}
        System.out.println(alipayProperties.toString());//AlipayProperties{appid='33333', email='xuchengfeifei@q163.com', key='2', productNo='3'}

        return alipay.toString();
    }
}
